<template>
  <view class="a-content">
    <view class="title">子组件A</view>
    <!-- A组件展示接收的intent值 -->
    <view class="a-box">
      父组件传入值：<text style="color: red;font-weight: bold;">{{ intent }}</text>
    </view>
    <!-- 新增：点击按钮向B组件传值 -->
    <button size="mini" @click="sendToB">点击给B传值</button>
  </view>
</template>

<script>
export default {
  name: "ComA",
  // 接收父组件传递的intent值
  props: {
    intent: {
      type: String,
      default: ""
    }
  },
  methods: {
    sendToB() {
      // 触发全局事件「fasong」，传递A的intent值（可自定义加工）
      uni.$emit("fasong", this.intent);
      console.log("A组件已发送值：", this.intent);
    }
  }
};
</script>

<style scoped>
.a-content {
  margin: 50rpx;
  padding: 20rpx;
  background-color: #99CCFF;
}
.a-box {
  height: 80rpx;
  display: flex;
  flex-direction: row;
  align-items: center;
  padding-left: 20rpx;
}
button {
  background-color: #007AFF;
  color: white;
}
</style>